//
//  CorePlayerAdapterType.swift
//  VideoPlayer
//
//  Created by JY_NEW on 2021/10/8.
//

import Foundation

/// 播放器相关状态通知
public protocol CorePlayerAdapterDelegate: AnyObject {
    /// 播放状态改变
    func playerAdapter(_ player: CorePlayerAdapterType, didChangeStatus status: CorePlayerStatus)
    /// 播放器尺寸改变
    func playerAdapter(_ player: CorePlayerAdapterType, didChangePresentationSize size: CGSize)
    /// 播放内容长度改变
    func playerAdapter(_ player: CorePlayerAdapterType, didChangeDuration duration: TimeInterval)
    /// 可播放内容长度改变
    func playerAdapter(_ player: CorePlayerAdapterType, didChangePlayableDuration duration: TimeInterval)
    /// 准备播放完毕
    func playerAdapterReadyForDisplay(_ player: CorePlayerAdapterType)
}

/// 播放器适配器
public protocol CorePlayerAdapterType: AnyObject {
    /// 必须用weak修饰
    var delegate: CorePlayerAdapterDelegate? { get set }
    var status: CorePlayerStatus { get }
    var presentationSize: CGSize { get }
    
    var rate: Float { get set }
    var volume: Float { get set }
    
    var currentTime: TimeInterval { get }
    var duration: TimeInterval { get }
    var playableDuration: TimeInterval { get }
    
    /// 跳转到指定时长
    func seek(to time: TimeInterval, completion: ((Bool) -> Void)?)

    func play()
    func pause()
    func stop()
    
    var view: UIView! { get }
    /// 是否准备好显示
    var isReadyForDisplay: Bool { get }
}
